package com.twh.www.service.login.impl;

import com.twh.www.entity.WnUser;
import com.twh.www.mapper.WnUserMapper;
import com.twh.www.service.login.LoginStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 邮箱登录适配器
 */
@Component
public class EmailLoginAdapter implements LoginStrategy {
    @Autowired
    private WnUserMapper userMapper;

    @Override
    public WnUser login(Object... credentials) {
        if (credentials.length < 1) {
            return null;
        }
        String email = (String) credentials[0];

        // 查找用户
        WnUser user = userMapper.getUserByEmail(email);
        if (user == null) {
            return null;
        }
        return user;
    }

    @Override
    public String getLoginType() {
        return "EMAIL";
    }


} 